Error using Trainer with Colab notebook, anyone have a solution?

from transformers import (
DistilBertTokenizer,
DistilBertForSequenceClassification,
Trainer,
TrainingArguments,
)
from transformers.trainer import Trainer
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
eval_dataset=test_dataset,
compute_metrics=compute_metrics
)
trainer.train()
Got this error: ValueError Traceback (most recent call last)
in <cell line: 0>()
1 # 7. Fine-tune the model
----> 2 trainer.train()

15 frames
/usr/local/lib/python3.11/dist-packages/datasets/formatting/formatting.py in _arrow_array_to_numpy(self, pa_array)
194 ):
195 return np.array(array, copy=False, dtype=object)
→ 196 return np.array(array, copy=False)
197
198

ValueError: Unable to avoid copy while creating an array as requested.
If using np.array(obj, copy=False) replace it with np.asarray(obj) to allow a copy when needed

1 Like

Perhaps numpy>=2 issue…?

in Colab:

!pip install numpy==1.26.4